package top.shaozuo.simple.configuration.microprofile.config.converts;

import org.eclipse.microprofile.config.spi.Converter;

public class BooleanConverter implements Converter<Boolean> {

    /**
     * 
     */
    private static final long serialVersionUID = 5030035706736512824L;

    public static final BooleanConverter INSTANCE = new BooleanConverter();

    @Override
    public Boolean convert(String value) {
        if (value != null) {
            return "TRUE".equalsIgnoreCase(value) || "1".equalsIgnoreCase(value)
                    || "YES".equalsIgnoreCase(value) || "Y".equalsIgnoreCase(value)
                    || "ON".equalsIgnoreCase(value);
        }
        return null;
    }
}